package com.bdmc.smokesensor.services;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.bdmc.smokesensor.dao.Sys_LogJPA;
import com.bdmc.smokesensor.entity.Sys_Log;
import com.bdmc.smokesensor.iservices.ISys_LogService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

@Service
public class Sys_LogService extends BaseService<Sys_Log> implements ISys_LogService {

    @Autowired
    private Sys_LogJPA _logJpa;

    @Override
    public List<Sys_Log> findAll() {
        return _logJpa.findAll();
    }


    @Override
    public Map<String, Object> findAllByPage(String page,String loginName, Pageable pageable) {
        Map<String,Object> map = new HashMap<String,Object>();
        
        Page<Sys_Log> data = _logJpa.findByPageContainingAndLoginNameContaining(page,loginName, pageable);
        map.put("total", data.getTotalElements());
        map.put("data", data.getContent());
        return map;
	}

    @Override
    public Sys_Log findOne(Example<Sys_Log> example) {
        return _logJpa.findOne(example).orElse(null);
    }

    @Override
    public Sys_Log findOneById(int id) {
        return _logJpa.findById(id).orElse(null);
    }

    @Override
    public Sys_Log save(Sys_Log log) {
        return _logJpa.save(log);
    }

	@Override
	public void deleteById(int id) {
        _logJpa.deleteById(id);
    }



}